<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Keu_approval_keu_umk extends MY_Controller {
	
	function __construct()
	{
		parent::__construct(); 
		
		$this->load->model('keu_umk_model', 'UMK');
		$this->load->model('keu_umk_detail_model', 'UMKDetail');
		$this->load->model('combo_model', 'Combo');
		$this->load->model('keu_coa_model', 'Coa');
		$this->secure_session();
	}
	
	function index(){
		$data['title'] = "Approval Pembuatan UMK - Manager Keuangan";
		$data['data'] = null;
		$data['data']['date_from'] = date('01/m/Y');
		$data['data']['date_to'] = date('t/m/Y');
		
		viewByTemplate('keu_approval_keu_umk/index', $data, 'grid');
	}
	
	function getdata()
	{
		$this->secure_session();
		echo $this->UMK->GetApprovalKeuJSON();
	}
	
	function approval()
	{	try
		{
			$li_num_row =intval($this->data['num_row']);
			if ($li_num_row>0){
				$st_new = false;
				$st_rev = false;
			
				for ($i = 0; $i < $li_num_row; $i++)
				{
					$data['st_approve_keu']	= 'Y';
					$data['tgl_approve_keu']= NOW;
					$data['user_approve_keu']	= USERID;
					
					
					$this->UMK->Update($data, 
										array('id_umk'	=> $this->data[$i]['id_umk']));
					
				}
				
				$is_error = 0; 
				$ls_response = 'UMK berhasil di approve';
			}else{
				$is_error = 1; 
				$ls_response = 'Silakan pilih data UMK!';
			}
		} catch(Exception $e) {
			$is_error = 1; $ls_response = $e->getMessage();
		}
		
		$arr_response = array("is_error"=> $is_error, "msg"=>$ls_response);
		echo json_encode($arr_response);
	}
	
	
	
}
?>